package com.xx.springboot.controller;


import com.xx.springboot.entity.ResponseBo;
import com.xx.springboot.service.ISyslogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.api.ApiController;

import java.util.Optional;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaoxiunique
 * @since 2018-11-05
 */
@RestController
@RequestMapping("/syslog")
public class SyslogController extends ApiController {

    @Autowired
    private ISyslogService syslogService;

    /**
     * <p>
     *     获取得到系统日志
     * </p>
     * @param pageNo
     * @param pageSize
     * @return
     */
    @RequestMapping("/getSysLogList")
    public ResponseBo getSysLogList(Integer pageNo, Integer pageSize) {
        pageNo = Optional.ofNullable(pageNo).orElse(0);
        pageSize = Optional.ofNullable(pageSize).orElse(10);

        if (pageNo < 0 || pageNo < 0) {
            return ResponseBo.error("分页条件不正确");
        }

        return syslogService.getSysLogList(pageNo, pageSize);
    }
}

